import {
	defineStore
} from 'pinia'
import {
	ref
} from 'vue'
export const userStore = defineStore("user", () => {
	// let token = ref("")
	let userInfo = ref({})
	let isLogin = ref(false)
	let currentPos = ref({
		latitude: 34.342,
		longitude: 108.9397
	})


	let hasPos = ref(false)

	function addUserInfo(password, username, token) {
		this.userInfo.password = password;
		this.userInfo.username = username;
		this.token = token;
		this.isLogin = true
		//自行添加内容
	}
	//清除用户登陆状态
	function clearUserInfo() {
		//自行添加内容
		this.userInfo = {}
		this.isLogin = false
		this.token = ""
	}

	function setPos(lat, lon) {
		currentPos.value.latitude = lat
		currentPos.value.longitude = lon
		hasPos.value = true
		console.log(currentPos.value)
	}
	return {
		userInfo,
		isLogin,
		addUserInfo,
		clearUserInfo,
		currentPos,
		setPos,
		hasPos
	}
})